﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Webbshop.ServiceReference1;

namespace Webbshop
{
    public partial class SearchResultPage : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var searchWord = Request.QueryString["q"];
                ShoppeServiceClient proxy = new ShoppeServiceClient();
                try {
                    if (searchWord != null)
                    {
                        searchResultView.DataSource = proxy.search(searchWord);
                    }
                    else {
                        searchResultView.DataSource = proxy.GetProducts();
                    }
                   
                }
                finally {
                    proxy.Close();
                }
                
                searchResultView.DataBind();
                
            }
        }
    }
}